package com.mop.sg2.map;

import java.lang.reflect.Field;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.mop.sg2.R;

public class ImageBean {

	int x = 0;

	int y = 0;

	int width = 0;

	int heigth = 0;

	Bitmap bitmap = null;

	String name;
	
	
	
	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}

	public int getHeigth() {
		return heigth;
	}

	public void setHeigth(int heigth) {
		this.heigth = heigth;
	}

	public Bitmap getBitmap() {
		return bitmap;
	}

	public void setBitmap(Bitmap bitmap) {
		this.bitmap = bitmap;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void initMap(Resources r, String[] data)
			throws IllegalArgumentException {
		if (data.length < 4) {
			throw new IllegalArgumentException();
		}

		int id = 0;
		// 获取图片
		try {
			Field idField =R.drawable.class.getField(data[0]);
			id = idField.getInt(new R());
			bitmap = BitmapFactory.decodeResource(r, id); 
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (NoSuchFieldException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		x=Integer.parseInt(data[1]);
		
		y=Integer.parseInt(data[2]);
		
		width=bitmap.getWidth();
		
		heigth=bitmap.getHeight();
		
		name=data[3];
		
		
	}
	

}
